
module TrieTests where

import Trie                
                
-- Testtrie

testTrie1 :: Trie Integer
testTrie1 = insert "Mathias" 2  (insert "Mal" 7 (insert "Erik" 2 (insert "Ma" 9 empty)))

testTrie2 :: Trie Integer
testTrie2 = insert "Hallo" 3  (insert "Erik" 3 empty)

testList1 :: [(String, Integer)]
testList1 = [("Martin", 2), ("Mathias", 6), ("Math",7),("Erik", 2),("Ma", 9)] 

-- Functions
testFunMapT :: Integer -> String
testFunMapT a = "s" ++ (show a)

testFunMapTK :: String -> Integer -> String
testFunMapTK s i = "key:" ++ (show s) ++ " - value:" ++ (show i)

testFunFilterT :: Integer -> Bool
testFunFilterT i = (i > 5)      

testFunFilterTK :: String -> Integer -> Bool
testFunFilterTK s i = (i > 5) || (s == "Erik")

testFunFoldT :: Integer -> Integer -> Integer
testFunFoldT i1 i2 = i1 + i2

testFunFoldTK :: String -> Integer -> String -> String
testFunFoldTK key i1 i2 = key ++ ": " ++show(i1) ++ " + " ++ i2

-- Tests
mapTtest :: Trie String
mapTtest = mapT testFunMapT testTrie1

mapTKtest :: Trie String
mapTKtest = mapTK testFunMapTK testTrie1

filterTtest :: Trie Integer
filterTtest = filterT testFunFilterT testTrie1

filterTKtest :: Trie Integer
filterTKtest = filterTK testFunFilterTK testTrie1

foldTtest :: Integer
foldTtest = foldT testFunFoldT 0 testTrie1

foldTKtest :: String
foldTKtest = foldTK testFunFoldTK "0" testTrie1

insertTrieTest :: Trie Integer
insertTrieTest = insertTrie testTrie1 testTrie2

asListTest :: [(String, Integer)]
asListTest = asList testTrie1 

fromListTest :: Trie Integer
fromListTest = fromList testList1